jclass={
    initPage:function(){
        // 绑定dom对象
        this.obj = {
            searchText:$('#searchText'),
        };
        // 声明全局变量
        this.data = {
            datatable:[],
            tableParams: {
                page:1,
                size:10
            }
        };
        this.getTopTableData()
        this.getTableList();
        // this.creatTable({data:{},total:0});
        this.init();
        this.bindEvent();
    },
    init() {
        let that = this
    },
    bindEvent() {
        let that = this
        

        // 查询
        $("#btn_refrash").click(() => {
            this.getTopTableData()
        })

        $("#btn_cong_error").click(function() {
            let self = this
            Jdialog.confirm({ message: "是否提交从链路异常请求" }).on(function (e) {
                if (e) {
                    $(self).hide()
                    $("#btn_cong_ok").show()
                }
            });
        })
    },
    getTopTableData() {
        jrequest.get("/api/departmental_information_top",{page:1,size:10}).then(res => {
            this.creatTableTop(res)
            $("#jtable_department_top").bootstrapTable('load',new Array(res.data));

        })
    },
    getTableList() {
        $("#jid_loading").show()
        jrequest.get("/api/departmental_information",this.data.tableParams).then(res => {
            this.data.datatable = res.data
            this.creatTable(res)
            $("#jtable_department").bootstrapTable('load',res.data);
            $("#jid_loading").hide()
        })
    },
    creatTableTop(res) {
        var self=this;
        var columnsTop = [
            {
              field: "primaryAccessStatus",
              title: "部平台主链路接入状态"
            },
            {
              field: "obeyAccessStatus",
              title: "部平台从链路接入状态"
            },
            {
              field: "vehiclePositionsNumber",
              title: "上报车辆位置数"
            },
            {
              field: "platformInformationStatistics",
              title: "部平台交互信息统计数"
            },
            {
              field: "dayPosition",
              title: "当日上报位置数"
            },
            {
              field: "crossDomainInformation",
              title: "跨域信息数"
            },
            {
              field: "crossDomain",
              title: "当日跨域信息数"
            },
            {
              field: "accessTime",
              title: "接入时间"
            }
        ];
        self.tableEvent("jtable_department_top",new Array(res.data),columnsTop,false,res.total);

    },
    creatTable:function(res){
        var self=this;
        var columnsOne = [
            {
                title : '序号',
                align: "center",
                formatter: function (value, row, index) {
                    //获取每页显示的数量
                    var pageSize=self.data.tableParams.size;
                    //获取当前是第几页
                    var pageNumber=self.data.tableParams.page;
                    //返回序号，注意index是从0开始的，所以要加上1
                    return pageSize * (pageNumber - 1) + index + 1;
                }
            },
            {
              field: "messageId",
              title: "消息ID"
            },
            {
              field: "messageType",
              title: "消息类型"
            },
            {
              field: "messageContent",
              title: "消息内容"
            },
            {
              field: "accessTime",
              title: "接收时间"
            }
        ];
        self.tableEvent("jtable_department",res.data,columnsOne,true,res.total);
    },
    tableEvent:function(id,data,columns,paginationShow,total){
        let that = this
        $('#' + id).bootstrapTable({
            method: 'get',
            cache: false,
            height: 320,
            pagination: paginationShow,
            pageSize: that.data.tableParams.size,
            pageNumber:that.data.tableParams.page,
            striped: true,
            columns: columns,
            sidePagination: 'server', // client or server
            totalRows: total,
            data :data,
            onPageChange: function (size, number) {
                console.log(number)
                that.data.tableParams.page = number
                that.data.tableParams.size = size
                that.getTableList()
            },
            formatNoMatches: function(){
                return '暂无数据';
            }
        });
    }    
}

$(function(){
    jclass.initPage();

});
